// pages/report/report.js
let app =  getApp();
//背景音乐的地址
let musicUrl = "http://www.kynix.top:8080/fileManager-1.0-SNAPSHOT/audio/bgm.mp3";
let back =wx.getBackgroundAudioManager();//背景音乐控制器

Page({

    /**
     * Page initial data
     */
    data: {
        datas:[],
    },

    //返回按钮
    return(e) {
        wx.navigateTo({
            url: './../head/head',
        });
    },

    //音乐启停控制
    controlMusic(e) {
        var that = this;
        if(app.globalData.musicController === true) {//正在播放
            back.pause();
            app.globalData.musicController = false
        }else {//正在暂停
            back.play();
            app.globalData.musicController = true
        }
    },

    //背景音乐播放控制
    backmusic(){
        player();
        function player(){
          back.title = "背景音乐";
          back.src = musicUrl;
          back.onEnded(() => {
            player();
          })
        }
    },

    /**
     * Lifecycle function--Called when page load
     */
    onLoad: function (options) {
        var that = this;
        //播放背景音乐
        that.backmusic();

        //获取展示数据并存入datas
        wx.request({
            url: app.globalData.urlHome + '/rep/one',
            data: {
                "openid": wx.getStorageSync('openid'),
            },
            header: {'content-type':'application/json'},
            method: 'POST',
            success: (result) => {
                that.setData({
                    datas: result.data,
                })
            },
            fail: () => {},
            complete: () => {}
        });
          
    },

    /**
     * Lifecycle function--Called when page is initially rendered
     */
    onReady: function () {

    },

    /**
     * Lifecycle function--Called when page show
     */
    onShow: function () {

    },

    /**
     * Lifecycle function--Called when page hide
     */
    onHide: function () {

    },

    /**
     * Lifecycle function--Called when page unload
     */
    onUnload: function () {

    },

    /**
     * Page event handler function--Called when user drop down
     */
    onPullDownRefresh: function () {

    },

    /**
     * Called when page reach bottom
     */
    onReachBottom: function () {

    },

    /**
     * Called when user click on the top right corner to share
     */
    onShareAppMessage: function () {
        var that = this;
        // 设置菜单中的转发按钮触发转发事件时的转发内容
        var shareObj = {
            title: "快来参加“世界地球日”答题活动，保护我们的地球，从你我做起！",// 分享的slogan
            path: '/pages/login/login',        // 分享的起始页面
            imageUrl: '',//自定义图片路径
        }
        return shareObj;
    }
})